4 Problem: 11488 - Hyper prefix sets
5 Author: Andrés Mejía-Posada
31 #define V(x, t, d) copy(x.begin(), x.end(), ostream_iterator<t>(cout, d)); cout << endl
40 for (int i
=0; i
<n
; ++i
) cin
>> s
[i
], maxLen
= max(maxLen
, (int)s
[i
].length());
45 //for (int i=0; i<n; ++i) for (int j=0; j<=maxLen; ++j) dp[i][j] = 0;
47 for (int j
=0; j
<s
[0].size(); ++j
) dp
[0][j
] = 1;
48 for (int i
=1; i
<n
; ++i
) dp
[i
][0] = 1 + (s
[i
][0] == s
[i
-1][0] ? dp
[i
-1][0] : 0);
51 for (int i
=1; i
<n
; ++i
){
52 for (int j
=1, m
= s
[i
].size(); j
<m
; ++j
){
54 if (j
< s
[i
-1].length() && s
[i
][j
] == s
[i
-1][j
] &&
55 dp
[i
][j
-1] > dp
[i
-1][j
-1]){
56 dp
[i
][j
] += dp
[i
-1][j
];
58 ans
= max(ans
, (j
+1)*dp
[i
][j
]);
62 // for (int i=0; i<n; ++i){
63 // for (int j=0; j<maxLen; ++j){
64 // printf("%1d ", dp[i][j]);